<script type="text/javascript" src="lib/jquery-1.7.1.min.js"></script>

<link rel="stylesheet" href="lib/jquery-tree/jquery.jOrgChart.css"/>
<script src="lib/jquery-tree/jquery.jOrgChart.js"></script>

<script src="daniel-tree.js"></script>


<div id="chart" class="orgChart"></div>
 


<script>

function echo (string)
{
    $('body').append(string+'<br>');
}

/*
     _A_
    /   \
   B     C
  /
 D 
   
*/

// root
var tree = new Tree('A');
var a = tree.getRoot();
var b = tree.addChild(a, "B");
var c = tree.addChild(tree.getParent(b), "C");
var d = tree.addChild(b, "D");

echo("a is root? " + tree.isRoot(a));
echo("c is ext.? " + tree.isExternal(c));
echo("d is int.? " + tree.isInternal(d));
echo("tree size = " + tree.getSize());

echo("children of a: " + tree.printChildren(a));
echo("tree elements: " + tree.listElements(tree.getRoot()));
var node_list = tree.getNodes(tree.getRoot(), new Array);
echo("# of nodes=" + node_list.length);

tree.swapElements(a, b);
echo("a now contains " + a.get());
echo("b now contains " + b.get());

var s = tree.replaceElement(c, "CC");
echo("c now contains " + c.get() + " but previoulsy had " + s);

echo("b has " + tree.getChildren(b).length + " child nodes");
tree.removeExternal(d);
echo("b now has " + tree.getChildren(b).length + " child nodes");

echo(tree.showHtml(tree.getRoot()));


jQuery(document).ready(function() {
    $("#org").jOrgChart({
        chartElement : '#chart',
        dragAndDrop  : false
    });
});
</script>


